<template>
	<view class="container">
		<top-back-navbar position="fixed" :title="pageInfos.title" :background="pageInfos.bgColor" :color="pageInfos.color"></top-back-navbar>
		<view class="big_title f-w-700">资产数据</view>
		<view :class="['cz-box',pageInfos.boxClassName]">
			<view class="cz-number">¥{{userInfo.credit2 || '0.00'}}</view>
			<view class="cz-text">可用资金</view>
		</view>
		<view>
			<block v-for="(item,index) in res" :key="index">
				<view class="cz-list-cell" hover-class="uni-list-cell-hover">
					<view class="cz-triplex-list">
						<text class="cz-name">{{pageInfos.title}}</text>
						<text class="cz-jine">¥{{item.num}}</text>
					</view>
					<view class="cz-triplex-list">
						<text class="cz-time">{{item.createtime}}</text>
						<text class="cz-num">{{item.remark}}</text>
					</view>
				</view>
			</block>
		</view>
		<view v-if="res.length == 0" style="padding-top: 300upx;">
			<image src="/static/searchlist.png" mode=""
				style="display: block;margin: 0 auto;width: 240upx;height: 240upx;"></image>
			<view style="text-align: center;color: #999;">暂时没有任何记录</view>
		</view>
	</view>
</template>

<script>
	import uniLoadMore from '../../../../components/uni-load-more.vue'
	export default {
		components: {
			uniLoadMore
		},
		data() {
			return {
				res: [],
				index: 2,
				loadingType: 0,
				contentText: {
					contentdown: "上拉显示更多",
					contentrefresh: "正在加载...",
					contentnomore: "没有更多了"
				},
				systemInfo: {},
				load: 0,
				openid: '',
				userInfo:'',
				pageInfos:{}, 
				queryObj:{
					'jb':{
						member:{
							query:{},
							path:'/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=member&app=1'
						},
						list:{
							query:{
								type:'credit2'
							},
							path:'/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=api.get_zc_list&app=1'
						},
						boxClassName:'',
						bgColor:'#001b4d',
						color:'#ffffff',
						title:'钱包-提现记录'
					},
					'gf':{
						member:{
							query:{ 
								type:'gf'
							},
							path:'/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=member&app=1'
						},
						list:{
							query:{
								type:'guofeng_money'
							},
							path:'/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=api.get_zc_list&app=1'
						},
						boxClassName:'cz-box-gf',
						bgColor:'#ffffff',
						color:'#000000',
						title:'国风-收益记录'
					},
					'fly_egg':{
						member:{
							query:{
								type:'fly_egg'
							},
							path:'/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=member&app=1'
						},
						list:{
							query:{
								type:'egg_money'
							},
							path:'/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=api.get_zc_list&app=1'
						},
						boxClassName:'cz-box-jd',
						bgColor:'#224f91',
						color:'#ffffff',
						title:'会飞的鸡蛋-收益记录'
					},
				}
			};
		},
		onLoad: function(e) {
			const inofs= this.queryObj[e.type]?this.queryObj[e.type]:null;
			if(!inofs)uni.showToast({title: '页面参数错误',icon: 'none',duration: 2000})
			this.pageInfos=inofs;
			uni.showLoading()
			this.$GetOpenid().then(res=>{
				this.openid = res;
				this.setAjax()
				this.creditAjax();
			})
		},
		methods: {
			creditAjax(){
				const data={
					...this.pageInfos.member.query,
					'openid': this.openid
				}
				uni.request({
				  url: this.$BASE_URL+this.pageInfos.member.path,
				  method: 'POST',
				  data:data,
				  header: {
				    'Content-Type': 'application/x-www-form-urlencoded'
				  },
				  success: res => {
				    this.userInfo = res.data
				  },
				  fail: () => {},
				  complete: () => {}
				});
			},
			setAjax() {
				const data={
					...this.pageInfos.list.query,
					'openid': this.openid
				}
				uni.request({
					url: this.$BASE_URL+this.pageInfos.list.path,
					method: 'POST',
					data:data,
					header: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					success: res => {
						console.log(res)
						if(res.data.error == 0){
							if (res.data.total > res.data.pagesize) {
								this.load = 1
							}
							this.res = Array.isArray(res.data.list)?res.data.list:[]
						}
					},
					fail: () => {},
					complete: () => {
						uni.hideLoading()
						uni.stopPullDownRefresh();
					}
				});
			}
		},
		onPullDownRefresh() {
			this.setAjax();
		},
		onReachBottom() {
			return;
			if (this.loadingType !== 0) {
				return;
			}
			this.loadingType = 1;
			uni.request({
				url: this.$BASE_URL+'/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=member.log.get_list&app=1&page=' +
					this.index,
				method: 'POST',
				data: {
					'openid': this.openid
				},
				header: {
					'Content-Type': 'application/x-www-form-urlencoded'
				},
				success: res => {
					if (res.data.result.list.length == 0) {
						this.loadingType = 2;
						return;
					}
					this.res = this.res.concat(res.data.result.list)
					this.loadingType = 0;
					this.index = this.index + 1;
				},
				fail: () => {},
				complete: () => {}
			});

		},
	}
</script>

<style lang="scss">
	.status {
		width: 100%;
		font-size: 24upx;
		background: #e0e0e0;
		text-align: center;
		color: #fff;
		margin-top: 21upx;
	}

	page {
		background-color: #f2f5fa;
		box-sizing: border-box;
	}

	.container {
		padding: 10rpx 30rpx 0 30rpx;
		height: 100%;
	}

	.big_title {
		font-size: 32rpx;
		color: #1e1310;
		font-weight: 600;
		padding: 20rpx 30rpx 10rpx 0;
	}

	.cz-box {
		border-radius: 20rpx;
		padding: 30rpx;
		background: #001b4d;

		.cz-number {
			font-size: 46rpx;
			font-weight: bold;
			color: #fff;
			text-align: center;
		}

		.cz-text {
			font-size: 24rpx;
			font-weight: bold;
			color: #fff;
			text-align: center;
		}
	}
	.cz-box-gf{
		background: transparent url(/static/images/home/gy_qb_bg.png) center no-repeat;
		background-size: 100% 100%;
	}
	.cz-box-jd{
		background-color: #224f91;
	}

	.cz-list-cell {
		padding: 30rpx;
		border-radius: 20rpx;
		box-shadow: 0px 2px 8px 3px rgba(235,235,235,0.4);;
		padding: 20rpx 30rpx;
		margin-top: 30rpx;
		background-color: #fff;

		.cz-triplex-list {
			height: 50rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
		}

		.cz-name {
			font-size: 28rpx;
			font-weight: 600;
			color: #1e1310;
		}

		.cz-jine {
			font-size: 28rpx;
			font-weight: 600;
			color: #c30004;
		}

		.cz-time,
		.cz-num {
			font-size: 24rpx;
			color: #888889;
		}
	}
</style>
